﻿using Furion.DependencyInjection;
using GWB.Application.System.AssignMenuActionManage.Dtos;
using GWB.Core.TableEntity;
using GWB.Supplier;
using Mapster;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GWB.Application.System.AssignMenuActionManage.AssignMenuActionService
{
    public class OwnerMenuActionService : SqlSugarDb, ITransient, IOwnerMenuActionService
    {

        /// <summary>
        /// 编辑菜单权权限
        /// </summary>
        /// <param name="inputDto"></param>
        /// <returns></returns>
        public async Task<bool> EditAssignMenuAction(OwnerMenuActionCreateOrUpdateInputDto inputDto)
        {
            using var tran = Db.UseTran();
            //删除过去的配置
            await OwnerMenuActionDal.Delete(x => x.Type == inputDto.Type 
                                                 && x.OwnerId == inputDto.OwnerId);
            //重新添加配置
            await OwnerMenuActionDal.Create(inputDto.Adapt<List<OwnerMenuAction>>());
            tran.CommitTran();
            return true;
        }

        //public async List<OwnerMenuActionOutDto> GetOwnerMenuActions(long ownerId  )
        //{

        //}
    }
}
